package vip.youngboy.freejump.listener;

import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.activiti.engine.delegate.event.ActivitiEventType;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class ExamineRecorder implements ActivitiEventListener {

    protected Map<ActivitiEventType, ExamineRecorderHandler> eventHandlers
            = new HashMap<>();

    @Override
    public void onEvent(ActivitiEvent event) {
        getEventHandler(event).handleEvent(event);
    }

    @Override
    public boolean isFailOnException() {
        return false;
    }

    protected ExamineRecorderHandler getEventHandler(ActivitiEvent event) {
        return eventHandlers.get(event);
    }

}
